console.log('公用js');
(function() {
	// 获取验证码方法
	function getCaptureFn() {
		$('#getCaptureFn').click(function() {
			let time = 60,
				timer;
			$('#getCaptureFn').text(time + 's')
			$('#getCaptureFn').removeClass('active')
			$('#getCaptureFn').addClass('disabled')
			timer = setInterval(() => {
				time--;
				$('#getCaptureFn').text(time + 's')
				if (time === 0) {
					$('#getCaptureFn').addClass('active')
					$('#getCaptureFn').text('获取验证码');
					$('#getCaptureFn').removeClass('disabled')
					clearInterval(timer)
				}
			}, 1000)
		})
	}
	// tap事件
	function tapHandle() {
		$(document).on("touchstart", function(e) {
			var $target = $(e.target);
			if (!$target.hasClass("disable")) $target.data("isMoved", 0);
		});

		$(document).on("touchmove", function(e) {
			var $target = $(e.target);
			if (!$target.hasClass("disable")) $target.data("isMoved", 1);
		});

		$(document).on("touchend", function(e) {
			var $target = $(e.target);
			if (!$target.hasClass("disable") && $target.data("isMoved") == 0) $target.trigger("tap");
		});
	}
	jQuery.extend({
		'getCaptureFn': () => {
			getCaptureFn()
		},
		'tapHandle': () => {
			tapHandle()
		}
	})
})();
